class Category < ActiveRecord::Base

  validates :name, presence: true
  validates :slug, presence: true
  validates :slug, uniqueness: true, if: -> { slug.present? }

  has_many :post_categories, dependent: :destroy
  has_many :posts, through: :post_categories
end
